<template>
  <div class="workshops_container">
    <dv-loading v-if="loading"></dv-loading>
    <table-header :name="title" icon="balance-scale" />
    <div class="workshops_main">
      <!-- 左侧 start -->
      <div class="item_box">
        <div class="title">
          <span>300万密控系统</span>
        </div>
        <div class="main">
          <div class="item"></div>
          <div class="item"></div>
        </div>
      </div>
      <!-- 右侧 start-->
      <div class="item_box">
        <div class="title">
          <span>200万密控系统</span>
        </div>
        <div class="main">
          <div class="item"></div>
          <div class="item"></div>
        </div>
      </div>
      <!-- 右侧 end -->
    </div>
  </div>
</template>
<script>
import TableHeader from "../../components/tableHeader/index";

export default {
  components: {
    TableHeader,
  },
  data() {
    return {
      loading: true,
      real: {},
      title: "密控系统",
      signArray: [],
    };
  },
  sockets: {
    connect: function(data) {
      console.log("连接connect", data);
      this.createSocket();
    },
    reconnect(data) {
      console.log("重新连接", data);
      // this.$sockets.emit("connect",1)
      this.$socket.connect();
    },
    disconnect() {
      console.log("socket已断开连接");
    },
    densitydata(data) {
      var temp = JSON.parse(data).densitydata[0];
      this.real = temp;
      console.log(this.real, "message");
      if (this.real) {
        this.signArray = [];
        for (var key in this.real) {
          if (key.indexOf("_fk16") != -1) {
            this.signArray.push({
              mark: key.slice(3, 6),
            });
          }
        }
        this.loading = false;
      }
    },
  },
  beforeDestroy() {
    this.$socket.close();
  },
  mounted() {
    this.createSocket();
  },
  methods: {
    //创建socket链接
    createSocket() {
      this.$socket.connect();
      this.$socket.emit("densitydata", { subscribe: true });
    },
  },
};
</script>
<style lang="scss">
.workshops_main {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: top;
  padding: 0 0.3rem;
  overflow: hidden;
  box-sizing: border-box;
}
.item_box {
  width: 50%;
  height: 100%;
}
.title span{
  width:100%;
  height: 100px;
  line-height: 100px;
  color:#fff;
}
.main{
  width: 100%;
  height: calc(100% - 100);
  .item{
    width:50%;
    height: 100%;
  }
}
</style>
